package com.hyzx.qbasic.admin.domain.repository.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hyzx.qbasic.admin.domain.dao.SysJobMapper;
import com.hyzx.qbasic.admin.domain.repository.ISysJobRepository;
import com.hyzx.qbasic.admin.model.po.SysJobPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *  仓储实现类
 *
 * @author 黄江华
 * @since 2019-03-19
 */

@Repository
public class SysJobRepositoryImpl implements ISysJobRepository {

    @Autowired
    private SysJobMapper sysJobMapper;

    @Override
    public PageInfo<SysJobPO> getPagedSysJobList(int pageNum, int pageSize, String beanName) {
        PageInfo<SysJobPO> pageInfo = PageHelper.startPage(pageNum, pageSize)
            .doSelectPageInfo(() -> sysJobMapper.getPagedSysJobList(beanName));

        return pageInfo;
    }

    @Override
    public SysJobPO getSysJobById(Integer jobId) {
        return  sysJobMapper.getSysJobById(jobId);
    }

    @Override
    public List<SysJobPO> getSysJobListByStatus(Integer jobStatus) {
        return sysJobMapper.getSysJobListByStatus(jobStatus);
    }

    @Override
    public boolean addSysJob(SysJobPO record) {
        return sysJobMapper.addSysJob(record) > 0;
    }

    @Override
    public boolean editSysJob(SysJobPO record) {
        return sysJobMapper.editSysJob(record) > 0;
    }

    @Override
    public boolean deleteSysJobByIds(List<Integer> idList) {
        return sysJobMapper.deleteSysJobByIds(idList) > 0;
    }
}
